<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>FAHAI-CMS</title>
<link rel="stylesheet" href="assets/css/login_style.css" type="text/css"/>
<%--<link rel="shortcut icon" href="assets/images/favicon.ico"/>--%>
<link rel="shortcut icon" href="http://7xkzac.com2.z0.glb.qiniucdn.com/fahailogo.png" type="image/x-icon"/>
</head>
<body>

<div class="login-container">
    <h1>法海后台登陆界面</h1>

    <div class="connect">
        <p>欢迎来到FaHai-CMS管理中心</p>
    </div>

    <form action="submitLogin" method="post" id="loginForm">
        <div>
            <input id="username" type="text" name="username" class="username" placeholder="用户名" autocomplete="off"/>
        </div>
        <div>
            <input id="loginPwd" type="password" name="password" class="password" placeholder="密码"
                   oncontextmenu="return false" onpaste="return false"/>
        </div>
        <div id='addLoginInfo'></div>
        <button type="button" id="login_btn" onclick="submitLoginForm()">登 录</button>
    </form>

    <a href="/register" hidden="hidden">
        <button type="button" class="register-tis">还有没有账号？</button>
    </a>
</div>

<!--加密-->
<script src="assets/js/jquery-1.11.1.min.js"></script>
<!--背景图片自动更换-->
<script src="assets/js/supersized.3.2.7.min.js"></script>
<script src="assets/js/supersized-init.js"></script>
<!--表单验证-->
<!--<script src="assets/js/login_validate.js"></script> 表单验证和滑入字体效果(滑入字体效果移出到superized) -->
</body>
<script>
    //<![CDATA[
    //表单提交
    function submitLoginForm() {
        $('#addLoginInfo').empty();
        var username = $('#username').val().trim();
        var password = $("#loginPwd").val().trim();
        if (password != null && password != "") {
            password = ($("#loginPwd").val()).trim(); //去空,不加密
        }
        $.ajax({
            url: "submitLoginParam",
            type: "POST",
//            async: false,
//            contentType: 'application/json',
            data: {"username": username, "password": password},
            success: function (data) {
                if (data.code == 1 && data.msg) {
                    $('#addLoginInfo').empty();
                    $('#addLoginInfo').append("<br/><div style= 'width: 304px;height:36px; border-radius: 5px;" +
                            "background-color: #7db72f;opacity:0.9; font-size: 18px;font-weight: 500; text-align: center'>" +
                            "<strong style='line-height: 36px'>登录成功</strong></div>");
                    var originUrl = data.data;
                    window.setTimeout(function () {
                        jumpToOriginUrl(originUrl);
                    }, 1000);
                } else {
                    $('#addLoginInfo').empty();
                    $('#addLoginInfo').append("<br/><div style= 'width: 304px;height:36px; border-radius: 5px;" +
                            "background-color: orangered;opacity:0.9; font-size: 18px;font-weight: 500; text-align: center'>" +
                            "<strong style='line-height: 36px'>" + data.msg + "</strong></div>");
//                    setTimeout($('#addLoginInfo').empty(), 3000);
                }
            }
        });
    }

    $("body").keydown(function() {
        if (event.keyCode == "13") {//keyCode=13是回车键
            $('#login_btn').click();
        }
    });
    /**
     * 跳转到原始访问页面
     * @param originUrl
     */
    function jumpToOriginUrl(originUrl) {
        window.location.href = originUrl;
    }
    //打开字滑入效果
    window.onload = function () {
        $(".connect p").eq(0).animate({"left": "0%"}, 600);
        $(".connect p").eq(1).animate({"left": "0%"}, 400);
    };
    //]]>
</script>
</html>